package org.aom.entity.menu;

import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.aom.entity.base.EditDataGridIdEntity;
import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
/**
 * 目录模块元素
 * @author Saya
 *
 */
@Entity
@Table(name="ss_module_item")
@Cache(usage = CacheConcurrencyStrategy.READ_WRITE)
public class ModuleItem extends EditDataGridIdEntity{
	

	private static final long serialVersionUID = 9069045823275431458L;

	private String name;
	
	private String icon;
	
	private String url;
	
	private Module module;
	
	private List<Menu> menus = new ArrayList<Menu>();

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getIcon() {
		return icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	@ManyToOne(fetch = FetchType.EAGER, cascade = { CascadeType.REFRESH })
	@JoinColumn(name = "module_id")
	public Module getModule() {
		return module;
	}

	public void setModule(Module module) {
		this.module = module;
	}

	@ManyToMany(targetEntity = Menu.class, fetch = FetchType.LAZY, cascade = { CascadeType.PERSIST }, mappedBy = "moduleItems")
	public List<Menu> getMenus() {
		return menus;
	}

	public void setMenus(List<Menu> menus) {
		this.menus = menus;
	}
}
